<template>
  <div class="content">
    <div id="attend" style="width: 100%; height: 100%"></div>
  </div>
</template>
<script>
import * as echarts from "echarts";
export default {
  data() {
    return {};
  },
  methods: {
    createEcharts() {
      var chartDom = document.getElementById("attend");
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        legend: {
          bottom: 5,
          itemWidth: 8,
          itemHeight: 8,
          itemGap: 10,
          textStyle: {
            color: "#333",
          },
        },
        grid: {
          top: "10%",
          left: "10%",
          right: "5%",
          bottom: "20%",
        },
        xAxis: {
          type: "category",
          //设置坐标轴字体颜色和宽度
          axisLine: {
            //这是x轴文字颜色 和轴线的颜色
            lineStyle: {
              color: "#182F26",
            },
          },
          axisLabel: {
            color: "#00734D",
          },
          // 刻度线是否显示
          axisTick: {
            show: false,
          },
        },
        yAxis: {
          type: "value",
          //设置坐标轴字体颜色和宽度
          axisLine: {
            //这是Y轴文字颜色
            lineStyle: {
              color: "#182F26",
            },
          },
          // 刻度线是否显示
          axisTick: {
            show: false,
          },
          splitLine: {
            lineStyle: {
              color: "#182F26",
            },
            show: true, //显示
          },
          axisLabel: {
            color: "#00734D",
          },
        },
        tooltip: {},
        dataset: {
          source: [
            [
              "product",
              "实验室主任",
              "高级实验师",
              "实验师",
              "助理实验师",
              "技术员",
              "实验员",
            ],
            ["1", 43.3, 85.8, 93.7, 20, 43.3, 85.8],
            ["2", 83.1, 73.4, 55.1, 10, 43.3, 85.8],
            ["3", 86.4, 65.2, 82.5, 56, 43.3, 85.8],
            ["4", 72.4, 53.9, 39.1, 78, 43.3, 85.8],
            ["5", 83.1, 73.4, 55.1, 10, 43.3, 85.8],
            ["6", 86.4, 65.2, 82.5, 56, 43.3, 85.8],
            ["7", 72.4, 53.9, 39.1, 78, 43.3, 85.8],
            ["8", 83.1, 73.4, 55.1, 10, 43.3, 85.8],
            ["9", 86.4, 65.2, 82.5, 56, 43.3, 85.8],
            ["10", 72.4, 53.9, 39.1, 78, 43.3, 85.8],
            ["11", 72.4, 53.9, 39.1, 78, 43.3, 85.8],
            ["12", 83.1, 73.4, 55.1, 10, 43.3, 85.8],
          ],
        },
        series: [
          {
            type: "bar",
            stack: "Ad",
            emphasis: {
              focus: "series",
            },
            barWidth: 23,
            itemStyle: {
              normal: {
                color: "#176B4A",
              },
            },
          },
          {
            type: "bar",
            stack: "Ad",
            emphasis: {
              focus: "series",
            },
            barWidth: 23,
            itemStyle: {
              normal: {
                color: "#3DC986",
              },
            },
          },
          {
            type: "bar",
            stack: "Ad",
            emphasis: {
              focus: "series",
            },
            barWidth: 23,
            itemStyle: {
              normal: {
                color: "#2AF3F2",
              },
            },
          },
          {
            type: "bar",
            stack: "Ad",
            emphasis: {
              focus: "series",
            },
            barWidth: 23,
            itemStyle: {
              normal: {
                color: "#FCE848",
              },
            },
          },
          {
            type: "bar",
            stack: "Ad",
            emphasis: {
              focus: "series",
            },
            barWidth: 23,
            itemStyle: {
              normal: {
                color: "#FF6B20",
              },
            },
          },
          {
            type: "bar",
            stack: "Ad",
            emphasis: {
              focus: "series",
            },
            barWidth: 23,
            itemStyle: {
              normal: {
                color: "#FF2069",
              },
            },
          },
        ],
      };

      option && myChart.setOption(option);
    },
  },
  mounted() {
    this.createEcharts();
  },

  beforeDestroy() {
    clearInterval(this.timer);
    this.timer = null;
  },
};
</script>
<style  scoped>
.content {
  width: 100%;
  height: 100%;
  background-size: 100% 100%;
}
.main {
  height: 100%;
  width: 100%;
}
</style>